Transactional and non-transactional data for maintaining session state

ABSTRACT

Transactional and non-transactional data for maintaining session state is described. In a session, a server instance receives, from a client, a request to execute transactional commands and non-transactional commands. The server instance sends at least one first directive executable at the client to store, in a first set of information, one or more first items representing one or more particular transactional commands that are open but not yet committed. The first set of information is maintained separately from a second set of information including one or more second items representing one or more particular non-transactional commands that have been processed. Based on committing one or more particular transactional commands, the server instance sends at least one second directive executable at the client to purge, from the first set of information, the one or more first items without purging, from the second set of information, the one or more second items.

CROSS-REFERENCE TO RELATED APPLICATIONS; BENEFIT CLAIM

This application claims the benefit as a Continuation, under 35 U.S.C.§120, of: (1) application Ser. No. 14/231,347, entitled “TransactionalAnd Non-Transactional Data For Maintaining Session State,” filed Mar.31, 2014, the entire contents of which is hereby incorporated byreference as if fully set forth herein, which claims the benefit as aContinuation, under 35 U.S.C. §120, of: (2) application Ser. No.13/563,680, entitled “Masking Database Outages From Clients AndApplications,” filed Jul. 31, 2012, the entire contents of which ishereby incorporated by reference as if fully set forth herein, whichclaims the benefit as a Continuation-in-part, under 35 U.S.C. §120, ofthe following applications: (3) application Ser. No. 13/229,641,entitled “Recovering Stateful Read-Only Database Sessions,” filed Sep.9, 2011, the entire contents of which is hereby incorporated byreference as if fully set forth herein; (4) application Ser. No.13/448,258, entitled “Idempotence For Database Transactions,” filed Apr.16, 2012, the entire contents of which is incorporated by reference asif fully set forth herein; (5) application Ser. No. 13/448,267, entitled“Idempotence For Database Transactions,” filed Apr. 16, 2012, the entirecontents of which is incorporated by reference as if fully set forthherein; and (6) application Ser. No. 13/542,278, entitled “PreservingServer-Client Session Context,” filed Jul. 5, 2012, the entire contentsof which is incorporated by reference as if fully set forth herein. Theapplicant(s) hereby rescind any disclaimer of claim scope in the parentapplication(s) or the prosecution history thereof and advise the USPTOthat the claims in this application may be broader than any claim in theparent application(s).

This application is also related to (1) U.S. Pat. No. 7,747,754,entitled “Transparent Migration Of Stateless Sessions Across Servers,”filed Aug. 12, 2004, the entire contents of which is incorporated byreference as if fully set forth herein; (2) U.S. Pat. No. 7,502,824,entitled “Database Shutdown With Session Migration,” filed May 1, 2006,the entire contents of which is incorporated by reference as if fullyset forth herein; (3) U.S. Pat. No. 7,552,218, entitled “TransparentSession Migration Across Servers,” filed Aug. 12, 2004, the entirecontents of which is incorporated by reference as if fully set forthherein; (4) U.S. Pat. No. 7,415,470, entitled “Capturing And Re-CreatingThe State Of A Queue When Migrating A Session,” filed May 17, 2005, theentire contents of which is incorporated by reference as if fully setforth herein; (5) U.S. Pat. No. 7,634,512, entitled “Migrating TemporaryData Of A Session,” filed Apr. 4, 2007, the entire contents of which isincorporated by reference as if fully set forth herein; (6) U.S. patentapplication Ser. No. 13/076,313, entitled “Application Workload CaptureAnd Replay System,” filed Mar. 30, 2011, the entire contents of which isincorporated by reference as if fully set forth herein.

TECHNICAL FIELD

The technical field relates to recovering in-flight client to servertransactional and non-transactional work.

BACKGROUND Servers and Clients

A server is an operating software process that provides a service to oneor more clients. The server may be a server instance of severaldifferent server instances of related software that are operating toprovide services to clients. Clients communicate with servers on serverconnections. In particular, clients send commands to servers, and theservers execute the commands and, optionally, send results back to theclients. As used herein, a server “operation” refers to a function,procedure, or other action taken by the server pursuant to executing oneor more commands the client. A single command may trigger multipleserver operations or may correspond to a single server operation. Forexample, some commands may request the server to return results inaddition to performing a data manipulation function. Other commands maymerely request confirmation that data manipulation commands wereperformed, or may not request any response.

A client may request execution of a set of commands that are specifiedin the request. In response, the server may execute the set of commandsand confirm, to the client, that the set of commands were executed. Forexample, the server may provide results to the client or may merelyprovide an indication that the set of commands were executed. Theconnection between the server and the client may become unavailable atany time, planned or unplanned. For example, the server may fail, or anetwork device or other resource supporting the connection between theserver and the client may fail. If the connection between the server andthe client becomes unavailable before the server has responded to a setof commands, the client is unable to determine whether or not the set ofcommands has been completed.

Database servers and database applications are provided herein asexamples of servers and clients, respectively. However, varioustechniques described herein may apply to any server-client system.

Database Instances

A database comprises data and metadata that is stored on one or morestorage devices, such as a hard disk, a stick of random access memory, acluster or a cloud storage system. Such data and metadata may be storedin a database logically, for example, according to relational and/orobject-relational database constructs. A database application interactswith an instance of a database server (“database instance”) bysubmitting, to the database instance, commands that cause the databaseinstance to perform operations on data stored in a database. A databasecommand is a request to access or modify data from a database. Thecommand may cause the database instance to perform operations on thedata in the database and/or return the data from the database.

In a multi-node database system, a database may be served by multipledatabase instances, and each database instance may be configured toaccess all or part of the database. An instance of a server is acombination of integrated software components, such as one or moreprocesses executing on one or more computing devices, and an allocationof computational resources, such as memory, storage, or processorcycles, for executing the integrated software components on a processor.A database instance is a combination of integrated software componentsand an allocation of computational resources for accessing, modifying,or otherwise using a database. Database instances may be grouped intological domains called services. Multiple database instances may beinstalled or configured on a single machine or on separate machines.When processing database commands, a database instance may access thedatabase or a cache of information from the database. In one example,the database is stored in non-volatile memory, and the cache is storedin volatile memory.

When multiple database sessions share access to the same data, usercommands executed in a session may lock a portion of the database whilethe portion is in use by a database instance serving the session. Forexample, the user session may lock the portion for exclusive read and/orwrite access, and other user sessions are prevented from accessingand/or modifying the portion while the portion is locked. The usersession then releases the lock when the database instance is finishedaccessing and/or modifying that portion of the database. After the lockis released, other instances may access and/or modify the portion orobtain a lock on the portion.

Database commands may be submitted to a database instance in the form ofdatabase statements that conform to a database language supported by thedatabase instance. One non-limiting example of a database languagesupported by many database instances is a Data Manipulation Language(“DML”) called Structured Query Language (“SQL”), including proprietaryforms of SQL supported by such database servers as Oracle®, (e.g.Oracle® Database 11 g). SQL data definition language (“DDL”)instructions are issued to a database server to create or configuredatabase objects, such as tables, views, or complex types. Although SQLis mentioned as one example, there are many other example databaselanguages and exposed interfaces to the database, any of which may beused in conjunction with the techniques described herein.

Procedural Language/Structured Query Language (“PL/SQL”) extends SQL byproviding constructs found in procedural languages, resulting in astructural language that is more powerful than standard SQL. PL/SQLcommands are organized into blocks of variable declarations,sub-commands that include procedural and SQL commands, andexception-handling commands. PL/SQL commands may be sent to a databaseserver to cause the database server to perform a variety of actions asthe PL/SQL commands are executed. The database server may also receiveand execute Java-based commands, remote procedure call commands, orcommands that conform to other programming languages or constructs.

Multiple database commands may be sent from a database client to thedatabase instance in a single request to perform work. The databasecommands may be processed by the database instance, and the databaseinstance may return results to the database client in a single responseto all commands that were submitted in the request. Handling multiplecommands in a single roundtrip request and response may result in anefficient use of database connections. In other words, clients generallyuse database connections to submit requests less frequently whenmultiple commands are allowed to be submitted on the requests that usethe database connections.

Applications and Logical Connections

Servers, such as mid-tier servers, provide database instance connectionsto applications that request information from a database. A mid-tierserver is a server that provides access to one or more database servers,distributes work to one or more database servers, or manages connectionsto one or more database servers. An application is any logic running onone or more computing devices that uses a database connection toretrieve information from the database. The retrieved information may bepresented or displayed to a user of the application. For example, theapplication may be accessed from a browser, where the applicationreceives input from the user and presents information to the user. Theapplication may be an application that is accessed through a web portal,over a network, by the user, an application that is installed on amachine of the user, or an application that is distributed amongmultiple machines.

In one example, an Oracle® Fusion® Application is specially configuredto retrieve data from an Oracle® database, and display the informationto a user of the Fusion® Application. Applications other than Oracle®Fusion® Applications currently exist, and other database applicationsmay be developed in the future without departing from the presentdisclosure.

In one example, an application issues a request to a mid-tier server fordata from a database. The request may or may not be sent in response touser input. The mid-tier server selects a free connection from amongstthe freed connections in the pool to database instances. A databaseconnection that has been selected and/or customized for use by a clientor group of clients is referred to herein as a “database session.” Adatabase connection may be customized to meet particular needs as adatabase session for a particular client, or the connection may begeneralized such that the connection can be used to support a variety ofdatabase sessions for a variety of clients. The mid-tier server sendsthe client request on the selected connection to a database instance,and the database instance accesses a database to handle the request. Thedatabase server processes the request by retrieving or modifying data inthe database or by retrieving or modifying the data in a cache of datafrom the database. The database server establishes state for thedatabase session as the database server processes the request.

Mid-tier servers often maintain connection pools, which includeconnections to database instances. The connection may refer to either aphysical mechanism, such as a physical port, or a logical configuration,or both. There may be a one-to-one mapping of logical connections (i.e.,database sessions) to physical connections. On the other hand, there maybe more than one logical connection associated with a single physicalconnection. In one example, the free connections in the connection poolinclude only those connections that are not allocated to applicationsfor processing requests. As work completes, connections are returned tothe connection pool and are available for subsequent applications toborrow from the pool.

Effect of Database Session Unavailability on the Application

As an application uses a database session to access a database, theapplication builds up state on the database session. For example,application uses the database session to obtain locks, create temporaryvariables or database objects, establish user-specific information,establish application-specific information, establish cursorinformation, create temporary arrangements or selections of data, and/orperform other partially completed operations on data for furtherprocessing in the database session. If the database session fails beforethe further processing occurs, the locks, temporary variables ordatabase objects, user-specific information, application-specificinformation, cursor information, temporary arrangements or selections ofdata, and/or the partially completed operations become unavailable tothe application, even if the application attempts to reference thisinformation in a new database session.

In one example, the database session may fail or otherwise becomesunavailable if a database instance upon which the database sessiondepends fails or otherwise becomes unavailable. In most cases, failureof the database session causes the application to fail as thein-progress database session is lost. The application's user mustrestart the application or components of the application and start overwith logging in, opening cursors and retrieving data, obtaining locks,creating temporary variables or database objects, establishinguser-specific information, establishing application-specificinformation, establishing cursor information, creating temporaryarrangements or selections of data, and/or partially completingoperations on data for further processing in the database session. Inone example, upon failure of the database session, the user may be lefthanging with a blue screen or interrupted with an error message.

In prior client-server systems, if there is a break between the clientand the server, the client sees an error message indicating that thecommunication failed. This error does not inform the client whether thesubmission executed any commit operations or if a procedural call, ranto completion executing all expected commits and session state changesor failed part way through or yet worse, is still running disconnectedfrom the client.

If the client wanted to know whether the submission to the database wascommitted, the client could have added custom exception code to querythe outcome for every possible commit point in the application. Giventhat a system can fail anywhere, this is impractical in general as thequery must be specific to each submission. After an application is builtand is in production, this is completely impractical. Moreover, a querycannot give an accurate answer because the transaction could commitimmediately after that query executed. Indeed, following a communicationfailure, the server may still be running the submission not yet awarethat the client has disconnected. For a PL/SQL or Java operation, orother procedure submitted to the database, there is no record as towhether the procedural submission ran to completion or was aborted partway through. While it may have committed, subsequent work may not havebeen done for that procedure.

Failing to recognize that the last submission has committed or shallcommit sometime soon or has not run to completion can lead to duplicatetransaction submissions and other forms of “logical corruption” as usersand software might try to re-issue already persisted changes.

Existing technologies do not provide information about the work that wasbeing executed by the resource when the resource became unavailable. Forexample, the application is not aware of the outcome of the lastoperation being processed by the resource in case of outages, planned orunplanned. If a server goes down while executing a set of commands, andbefore the server sends a response to a client for the set of commands,the client is unaware of whether the set of commands was executed by theserver before the outage. Even highly complex applications may exposeoutages to the end users.

Users experiencing resource outages may be frustrated and may loserevenue due to missed business opportunities, decisions made using baddata, troubleshooting expenses, and lost time in restarting theapplication or redoing the work. Some applications warn the user not tohit the submit button twice, and, when not the warning is not heeded byusers, duplicate transactions may be created if both submissions areallowed to complete.

In another example, once the database session has failed, the user maybe prevented from entering any information or causing any commands to besubmitted to the database before the page is reloaded. Also, reloadingthe page without checking what data was stored to the database couldlead to a duplicate submission. The application may prevent the userfrom submitting any commands that depend on the state that was lost inthe failed database session or may misbehave if needed information is nolonger available. In a particular example, fields already presented tothe user may be grayed to indicate that, in order to avoid corruptingdata stored in the database, the fields can no longer be modified by theapplication.

Even if the database session fails over to a second database instance,the second database instance may not have any information about thedatabase session beyond what was committed to the database prior to thefailure. In order to avoid corrupting the data in the database,applications may reset the information that is displayed to the user toinformation that matches the data already committed to the database. Inother words, when a database instance fails, a user may lose temporaryinformation that would have been available to the user just prior to thefailure. Some of the lost information may correspond to information thatwas being displayed, modified, selected, or arranged by the applicationand/or user that was using a now unavailable database session, orinformation that was about to be returned to the application and/or useron the now unavailable database session. The user is often forced tore-enter fields of data again.

The loss of information already entered, modified, selected, and/orarranged by a user may result in user frustration and wasted time inre-entry, re-modification, re-selection, and/or re-arrangement of theinformation after the application or application component hasrestarted. The lost information may be information that was retrieved bythe user from others, for example, by video, voice, email, or textmessage. In some cases, the lost information may no longer beretrievable. Losing information can be particularly costly when the useris being assisted by a support service provider as the failure occurs.Loss of information may require further communications with the supportservice provider, or may even cause the user to lose faith in thereliability of the application, the mid-tier server, or the databaseserver, or the company that provides the application, the mid-tierserver, and/or the database server. Further, the user may be selecting,entering, or modifying time-sensitive information prior to failure.Requiring the user to re-enter the time-sensitive information after thefailure may result in a delay that causes loss of business, value, orreputation of the user to business clients or business ventures of theuser. Requiring re-entry may also result in a loss of opportunity forthe user. For example, the user may miss out on items or opportunitiesthat the user had previously selected.

The approaches described in this section are approaches that could bepursued, but not necessarily approaches that have been previouslyconceived or pursued. Therefore, unless otherwise indicated, it shouldnot be assumed that any of the approaches described in this sectionqualify as prior art merely by virtue of their inclusion in thissection.

Fast Application Notification

Application developers develop applications that deal with reportedoutages of underlying software, hardware, underlying communicationlayers, or other resources in a server-client system. For example, sinceOracle 10g, Fast Application Notification (“FAN”) delivers notificationsto applications when a resource comes up (i.e., becomes available) orgoes down (i.e., becomes unavailable), and application developers maycustomize their applications to change application behavior in responseto the notifications.

BRIEF DESCRIPTION OF THE DRAWINGS

In the drawings:

FIG. 1 shows an example server-client workflow for recording work atreplay driver level, directing the driver, managing replay context, andachieving transaction idempotence.

FIG. 2 shows an example server-client workflow for failover for adatabase system driven by Continuity Management, Replay Driver andidempotence protocols for achieving at-most once execution oftransactions.

FIG. 3 shows an example architecture and component placement forclient-driver replay (termed Replay Driver) and WebLogic Server basedreplay.

FIG. 4 shows an example computer-implemented method for directing aclient to store information to maintain for a possible replay ofcommands that may or may not be transactional.

FIG. 5 shows an example computer-implemented method for receivinginformation from a client to replay commands that may or may not betransactional.

FIG. 6 illustrates an example computer system that may be speciallyconfigured to perform example methods described herein.

DETAILED DESCRIPTION

In the following description, for the purposes of explanation, numerousspecific details are set forth in order to provide a thoroughunderstanding of the present invention. It will be apparent, however,that the present invention may be practiced without these specificdetails. In other instances, well-known structures and devices are shownin block diagram form in order to avoid unnecessarily obscuring thepresent invention.

General Overview

Techniques are disclosed herein for recovering the state of a databasesession. The techniques can also be used to determine whether atransactional set of commands has completed or partially completed. Forexample, a set of commands may be partially completed if transaction(s)have committed but other transaction(s) have not committed, if there wasmore information to return with a commit outcome for the set ofcommands, or if there was otherwise more work to do by the server tocomplete the set of commands. Although the techniques may be describedwith reference to specific embodiments, the functionality describedherein may be provided by the performance of a method performed byspecialized software and/or hardware operating on one or more computingdevices, by a set of one or more stored instructions that, whenexecuted, cause performance of the method, or by a set of one or moremachines configured with specialized hardware and/or software to performthe method.

Using techniques described herein, state that was built up on a firstdatabase session between a first server instance and a client may berestored to a second database session between a second server instanceand the client. State that affects execution of commands in a sessionbut is not persisted to the database is called non-transactional sessionstate. Non-transactional session state, such as variables, objects,references, and settings that were created for the first session, may bepreserved by repeating non-transactional commands in the second session.Transactions may be executed in the second session only when thetransactions did not commit in the first session.

In one embodiment, a first server instance sends, to a client in a firstsession between a first server instance and the client, information tomaintain for a possible replay of command(s) that were sent in a requestto the first server instance for execution in the first session. If thefirst session becomes unavailable or if the client otherwise wishes tore-establish state of the first session to a second session, thecommand(s) may be replayed in the second session between a second serverinstance and the client. If replayed in the second session according tothe maintained information, the command(s) would re-establish a statethat was established between the first server instance and the client inthe first session, without re-making any changes to a database that werealready made in the first session. If the command(s) had been fullyexecuted or partially executed in the first session, the command(s) mayhave caused the first server instance to commit transaction(s) to makechanges to the database. In one embodiment, the command(s) did cause thefirst server instance to complete transaction(s) to make change(s) tothe database.

FIG. 4 shows an example computer-implemented method for directing aclient to store information to maintain for a possible replay ofcommands that may or may not be transactional. In step 400, a firstsession is established between a first server instance and a client bychecking the first session out from a connection pool and/or marking thesession to begin request(s). A beginning of a request is signaled by theclient and detected by the first server instance in step 401. In step402, the first server instance receives one or more commands from theclient for execution in the first session. The one or more commandsinclude zero commands or at least one command that, if executed, wouldcommit a transaction to make changes to a database. The first serverinstance sends, to the client in step 404, information to maintain for apossible replay of the one or more commands in a second session betweena second server instance and the client. The information supports replaywithout making any changes to the database that were already made in thefirst session. The first server instance may repeat steps 402 and 404for a set of commands in the request. After the first server instancerepeats steps 402 and 404 for the set of commands in the request, anending of the request is signaled by the client and detected by thefirst server instance, in step 405. To signal the end of the request,the session may be returned to the connection pool, and/or the requestmay be marked as ended.

The first server instance may direct the client to maintain informationby sending the client directive(s), and the maintained information maybe used by the second server instance to restore the state of the firstdatabase session to the second database session. In one embodiment, thedirectives may be piggybacked on messages sent between the client andthe first server instance. For example, directive(s) may be piggybackedon message(s) that include result(s) of executing command(s) in thefirst session. Example directives include, but are not limited to,“place in queue N,” “disable replay,” and “purge queue N”.

A request is a unit of work submitted from the application to a serverinstance on a database session. The request may include or referencedatabase commands such as SQL and PL/SQL, and other database calls of asingle web request on a single database connection. The request may bedemarcated by the calls made to check-out and then check-in the databaseconnection from a connection pool.

In one embodiment, a mid-tier server assigns a logical connection to anapplication that is requesting access to the database. The logicalconnection is mapped, directly or indirectly, to one of a plurality ofphysical connections. The logical connection may be re-assigned to newphysical connections without re-assigning a new logical connection tothe application. The logical connection may be exposed to theapplication, and the application may continue to reference the samelogical connection as the underlying physical connections change. In oneexample, a particular logical connection is represented as a connectionobject that is exposed to the application and that is mapped to anotherconnection object, which may or may not be exposed to the application,and which may or may not be another logical connection. Through ahierarchy of logical connections, the particular logical connection ismapped to a physical connection.

In one embodiment, the first server instance causes the client tomaintain information associated with transaction(s) in a different queueor storage location than information that is not associated with thetransaction(s). In this manner, information about transaction(s) may bepurged or cleared as the transaction(s) are completed so long as thecommands on the transactional queue also did not alter non-transactionalstate that is used by later commands. For example, the first serverinstance may direct the client to store a first set of informationrelated to transaction(s) in a first queue and a second set ofinformation not related to the transaction(s) in a second queue. Whenthe transaction(s) are completed, the first server instance may directthe client to purge or clear the information stored in the first queuedependent on how state that was not persisted was changed and used. Ifattempting to restore state to the second session, the client may replaysome commands without replaying other commands that were cleared priorto replay.

In one example, the first server instance causes the client to maintainseparate sets of information for transactional and non-transactionalstatements that were executed in the first session. In the example, afirst set of information may identify statement(s) that made temporarychange(s) that have not yet been made permanent in the database. Whenthe temporary change(s) are made permanent or committed to the database,the first server instance may efficiently instruct the client to purgeor clear the first set of information if these statements also did notmake non-transactional state changes. The second set of information mayidentify statement(s), such as non-transactional statements, that wereexecuted before or after transaction(s) that completed in the firstsession and so is not part of the transaction. Dependent on the mode ofoperation detected, purging the first set of information may leave thesecond set of information intact at the client, such that thenon-transactional statements identified in the second set of informationmay still be available for replay. Replaying the non-transactionalstatements in the second set of information may cause a second serverinstance in a second session to re-establish non-transactional statethat was originally established in the first session or would have beenestablished in the first session if the set of commands sent by theclient in the request had been executed to completion.

Conversely, if the statements in the first set of commands, namely thetransaction, also made non-transactional state changes, then, when thattransaction committed the first and second sets of information replaycould be disabled and both queues purged. These statements inside thetransaction may set state that is not persisted in the database andcannot be restored after the transaction committed unless a third set ofcommands is retained. For example, a variable may be defined after anINSERT or UPDATE statement, but before the INSERT or UPDATE has beencommitted to the database. Purge and disable can be used to avoid therisk of referencing missing information when attempting to rebuild thenon-transactional state and to avoid the risk of duplicating atransaction. Replaying is not valid in this second case because it wouldinvolve replaying a committed transaction unless that state is rebuiltwithout persisting the transactional state such as by using a third setof commands.

In one embodiment, commands might not be placed into any queue. Forexample, a SELECT statement might not be needed for replay if theinformation requested by that SELECT is meta-data that would be acquiredagain at replay. These commands may be queued on an as-needed basis ifthey are needed for replay. Commands may be purged from the queue as therequest executes because all data has been returned from them and theyare not needed to build non-transactional state.

A session is defined to have a static state if all session state changes(e.g. NLS settings, PL/SQL package state) occur as part ofinitialization, or otherwise outside of all transactions, and can beencapsulated in a callback at failover. If the client is operating in astatic mode, then the application does not later rely on or referenceinformation that was set by non-transactional statements that executedduring committed transactions, or will not make non-transactionalchanges after the request has been initialized. State created during atransaction that was not persisted does not need to be restored to thesecond session if the transaction has completed because, once thetransaction has committed, the later commands do not rely on orreference the information. Because the later commands do not rely onnon-transactional information set inside the transaction, theinformation stored in the transactional queue may be cleared from thetransactional queue safely when the transaction commits. This type ofapplication is often referred to as database agnostic. It does notchange PL/SQL variables or other constructs that changenon-transactional state during the request execution.

A session is defined to have dynamic state if the session state changesare not fully encapsulated by the initialization and cannot be fullycaptured in a callback at failover, but rather are included within therequest. If the application is operating in dynamic mode, then theapplication may or may not rely on or reference information that was setby non-transactional statements that executed during transactions.Because a transaction that was already executed in a first sessioncannot be repeated in a second session, non-transactional statementsnested within the transaction might not be available for replay in thesecond session after a transaction commits and completes unless a thirdset of commands is maintained.

Static state may be detected if non-transactional state not was changedwithin a request. For static mode, after a commit, the transaction queueis purged and replay can continue. Dynamic state may be detected ifnon-transactional state was changed within a request. Dynamic state isfurther characterized as to whether non-transactional state changedduring a transaction that committed was later referenced by a commandafter that transaction committed.

In one embodiment for static state, the first server instance receives arequest to execute commands and, before or during execution of thecommands, detects that a transaction in the request includes not onlytransactional commands that commit changes to the database, but alsocommands that change a state of the session but may not commit anychanges to the database. Not all requests include transactionalcommands, let alone transactional commands that set non-transactionalsession state. Many applications by default do not set non-transactionalsession state in transactions or at least agree not to rely on (or lateruse) any non-transactional session state that was set duringtransactions. Transactions that do not set non-transactional sessionstate may be purged as they are completed such that these transactionsare not repeated.

In one embodiment for dynamic state, upon detecting that a committedtransaction sets non-transactional session state, the first serverinstance may then determine whether or not later commands in thatrequest use the non-transactional session state. If later commands inthe request do not use the non-transactional session state, then thenon-transactional session state may be purged with the transaction on orafter completion of the transaction. The purging occurs when the firstserver instance sends an instruction to the client to delete informationabout the transaction, which may be stored in a first data structuresuch as a queue. In this scenario, because the state and the transactionare purged, and because the state is not used by later commands in therequest, commands in the request may be replayed without rebuilding thestate and without repeating the transaction.

In one embodiment for dynamic state, if later commands in the requestmay use the non-transactional session state, then the non-transactionalsession state cannot be purged along with the transaction when thetransaction is completed. In this case, the first server instance maysend information to the client that describes command(s) that, ifexecuted, would set the non-transactional session state withoutrepeating the transaction. In one example, these commands may includemany or all commands from the transaction without taking locks andexcluding commit operation(s). In other words, even though thetransaction has completed, the first server instance may send, to theclient, the commands of the transaction followed by a rollbackoperation. The commands may be further processed to execute notransactional actions such as taking out locks on shared data objects inthe database, modifying data, and also do not violate integrityconstraints.

In one embodiment for dynamic state, if later commands in the requestmay use the non-transactional session state, and if thenon-transactional session state cannot be restored without committingthe transaction, then the first server instance determines a checkpointat which a later command may rely on the non-transactional sessionstate. The server may instruct the client to record specialized commandsthat did not appear in the transaction but that are useable by a secondserver instance to restore the non-transactional session state changemade by the transaction. In one example, the state is recorded as a fullor delta of the state change made by the transaction using transparentsession migration. This state change may be represented by one or morecommands that effectuate the state change without repeating anytransactions.

For dynamic state, consider an example where a request includes SELECT,INSERT, ALTER, PL/SQL, COMMIT, and SELECT statements, in that order. Thefirst SELECT may be placed in a non-transactional queue. The INSERT maybe placed in a transactional queue along with the ALTER and PL/SQL,which was executed during the transaction. Execution of the COMMITcauses the transactional queue to be cleared when operating in staticmode. If the ALTER and PL/SQL made only non-transactional changes thesemay be placed into the non-transactional queue. This process leaves thetransactional queue empty and the first SELECT, PL/SQL and ALTER in thenon-transactional queue.

In another example, if non-transactional state changed within thetransaction and the commands cannot be located to the non-transactionalqueue then in one embodiment, the server instance may direct the clientto purge all queues and disable replay until the end of the request.Replay would be re-enabled when the next request begins. Replay isdisabled only when a non-transactional state change is detected inside atransaction that successfully commits and that non-transactional stateis relied on by a later command. Replay is disabled either at thecommit, or at the command that relies on that state. Most requestscontain no more than one commit and have commit as the last statement,and, at least in these cases, disabling is not an issue. Disable is aneffective technique for web requests as it incurs no burden at runtime.

For requests that execute commit and if an outage occurs immediatelyafter the commit executes but the commit outcome and directives are notreceived by the client, then replay returns the committed state. In thisway the user or application does know the outcome of the lasttransaction. When using static state, the transaction queue is purgedand capture for that request continues until the request ends. Whenusing dynamic state, after a successful commit replay is either disabledor a third set of commands is maintained to restore that state.

In one embodiment, a second server instance receives, from a client in asecond session between the second server instance and the client,information that was maintained for a possible replay, in the secondsession, of command(s) that were sent in a request from the client to afirst server instance for execution in a first session. The secondserver instance replays the command(s) in the second session accordingto the information maintained by the client to re-establish a state thatwas established between the first server instance and the client in thefirst session, without re-making any changes, to a database, that werealready made in the first database session. If the command(s) had beenfully executed or partially executed in the first session, thecommand(s) may have caused the first server instance to completetransaction(s) to make changes to the database. In one embodiment, thecommand(s) did cause the first server instance to completetransaction(s) to make change(s) to the database.

FIG. 5 shows an example computer-implemented method for receivinginformation from a client to replay commands that may or may not betransactional. FIGS. 4 and 5 can be performed separately or together. Instep 500, a second session is established between a second serverinstance and a client for a possible replay of commands that werepreviously sent in a request from the client to a first server instancein a first session. In step 501A, the second server instance mayre-establish fast application notification in case there is anotheroutage. In step 501B, a beginning of a request is signaled by the clientand detected by the second server instance. The second server instancereceives, from the client in step 502, information that was maintainedfor a replay of one or more commands that were sent in a request fromthe client to a first server instance in a first session. The one ormore commands include zero commands or at least one command that, ifexecuted, would commit a transaction to make changes to a database. Instep 504, the second server instance replays and validates replay forthe one or more commands in the second session, according to theinformation maintained by the client, to re-establish a state that wasestablished between the first server instance and the client in thefirst session, without re-making any changes, to the database, that werealready made in the first session. Steps 502 and 504 may be repeated forthe commands that were previously sent for execution in the firstsession. After the second server instance repeats steps 502 and 504 forthe commands that were previously sent for execution in the firstsession, and if validation is successful for each iteration of step 504,replay ends and the client returns to capture mode for the same requestin step 505A. In step 505B, an ending of the request is signaled by theclient and detected by the second server instance.

In one embodiment, the information received for replay includesdifferent sets of information, one set associated with transactions(s)that were not completed or committed in the first database session andanother set not associated with the transaction(s). Informationassociated with transaction(s) that were completed or committed in thefirst session may be purged as the transaction(s) are completed. Inother words, information associated with completed transactions mightnot be included in the information received for replay.

In one embodiment, the second server instance receives separate sets ofinformation for transactional and non-transactional statements that wereexecuted in the first session. For example, a first set of informationmay identify statement(s) that made temporary change(s) that have notyet been made permanent in the database. When the temporary change(s)are made permanent or committed to the database, the client may purge orclear the first set of information. The second set of information mayidentify statement(s), such as non-transactional statements, that wereexecuted before or after transaction(s) that completed in the firstsession. Purging the first set of information may leave the second setof information intact at the client, such that the non-transactionalstatements identified in the second set of information may still beavailable for replay. Replaying the non-transactional statements in thesecond set of information may cause a second server instance in a secondsession to re-establish non-transactional state that was originallyestablished in the first session or would have been established in thefirst session if the set of commands sent by the client in the requesthad been executed to completion.

In one embodiment, the first set of information that is cleared astransaction(s) are committed may also identify functions or statement(s)that were executed during the transaction(s) even if those statement(s)did not make any changes to the database. These statements may set statethat is not persisted in the database but may have remained in the firstdatabase session after the transaction(s) have completed. If the clientis using static state, this information may be stored in thetransactional queue and safely be cleared from the transactional queueas the transaction completes. On the other hand, if the client is usingdynamic state, then the non-transactional information may be lost whenthe transaction is cleared. To avoid the risk of relying on missingnon-transactional information, replay is disabled until the end of therequest safely eliminating any possibility of logical corruption. In oneembodiment, the second server instance may attempt to replaynon-transactional commands even if the non-transactional commands werenested within a transaction, modifying the commands as necessary toensure that the proper dependencies are in place to support execution ofthe non-transactional commands and also to ensure that the second serverinstance does not re-perform any transactions that were alreadyperformed in the first session. In this embodiment while the commandsran inside the transaction they were placed on the non-transactionalqueue so as to not be purged.

During replay, each replayed command is validated. The incoming commandmust have the right security, the right protocol, and right environment.After execution, all results returned to the client must be exactly thesame as they were during the first execution. This includes rows, androw order, out binds, error codes and error messages. Every piece ofinformation that the application or client potentially made a decisionon must be exactly the same as they were during the original execution.If any value that is placed on the wire from server to client changesfrom the original then replay is rejected and the client sees theoriginal error. Conversely, if the client executes server side code thatdoes not return results to the client, then the client trusts this codeexecution and the results may differ without consequence. In thisembodiment, the returned values are checked against a checksum such as aCRC calculated at original and replay. The cost of the checksum isoffloaded to hardware when hardware support is available.

Before and after replay, the relevant non-transactional environment mustbe correct for replay to succeed. That is, settings such as the decimalpoint position, the language, the currency, the sys_context and so oncan each impact stored results and must be the same as originalexecution. Checks occur before an execution to ensure that the call tobe replayed has the correct environmental state, and after execution, asthe current call may be the last call for which the client holdsinformation, and the next call must execute in the right environment. Inthis embodiment, the environment is checked against an environment hashvalue. If any check fails, the replay is rejected and the original erroris returned.

In one embodiment, commands are replayed by the second server instanceat the original system change number (“SCN”), or logical time that thecommands were executed by the first server instance, until a command isreached that cannot be replayed at the original SCN. From that pointforward, commands are replayed at the current SCN. As commands arereplayed, client-visible results from replay are compared toclient-visible results obtained during runtime, as indicated in thereplay context.

In one embodiment, the second server instance receives, from the client,information that describes command(s) that, if executed, would setnon-transactional session state that was set during a transactioncompleted in the first session, and the second server instance uses thisinformation to rebuild the non-transactional session state in the secondsession without repeating the transaction. In one example, thesecommands may include many or all commands from the transaction and/oroperations that would lock any shared data. The information may describespecialized commands that did not appear in the transaction thatcompleted in the first session but that are nonetheless useable by thesecond server instance to re-establish the non-transactional sessionstate.

In one embodiment, if later commands in the request may use thenon-transactional session state, and if the non-transactional sessionstate cannot be restored without committing the transaction, then thesecond server instance also receives, from the client, a checkpoint atwhich a later command may rely on the non-transactional session state.When the second server instance reaches the checkpoint during replay,replay is disabled and the transaction is not repeated. In one example,the state was recorded using transparent session migration, taking fullstate or a delta of the state changed by the transaction. This statechange may be represented by one or more commands that effectuate thestate change without repeating any transactions.

Mutable Functions and Replaying

When a request is replayed, the default and desired treatment of mutableobjects can vary. A mutable function is a function that obtains a newvalue each time that it is called. The new value may vary each time thatfunction is called. An example of a mutable is a call to SYSTIMESTAMPfunction. Client applications being recovered after an outage candetermine whether to keep or ignore the result of a mutable function ifthe request is replayed.

Mutable function values may be kept for SYSDATE, SYSTIMESTAMP,CURRENT_TIMEZONE, SYS_GUID, and sequence.NEXTVAL. Mutable values mayalso be kept for many other mutable functions such as MIN, MAX,CURRENT_TIMESTAMP, LOCAL_TIMESTAMP and so on. If the original values arenot kept and if different values for these mutable functions arereturned to the client, replay will be rejected because the client maysee different results. If the application can use original values, theapplication can configure the behavior of mutable functions using thenew KEEP clause for owned sequences and GRANT KEEP for other users.Sequence values may be kept at replay for many applications to providebind variable consistency.

Table 1.1 shows examples of the treatment of mutable functions byproducts during replay. (Actual implementation depends on specificproducts and releases.)

TABLE 1.1 Example Treatment of Mutable Objects by Products During ReplayMutable function Product 1 Product 2 Product 3 SYSDATE, OriginalOriginal Current SYSTIMESTAMP Sequence NEXTVAL Original Original (Notapplicable) and CURRVAL SYS_GUID Original (Not applicable) (Notapplicable) LOB access Fail on (Not applicable) (Not applicable)mismatch

To allow replay to keep and use original function results at replay:

-   -   The database user running the application may have the KEEP DATE        TIME and KEEP SYSGUID privileges granted, and the KEEP SEQUENCE        object privilege on each sequence whose value is to be kept. For        example:    -   grant KEEP DATE TIME to user2;    -   grant KEEP SYSGUID to user2;    -   grant KEEP SEQUENCE on sales.seq1 to user2;    -   Note that GRANT ALL ON <object> does not include (that is, does        not grant the access provided by) the KEEP DATE TIME and KEEP        SYSGUID privileges and the KEEP SEQUENCE object privilege.        -   Do not grant DBA privileges to database users running            applications for which replay is to be enabled. Grant only            privileges that are necessary for such users.

Sequences in the application may use the KEEP attribute, which keeps theoriginal values of sequence.NEXTVAL for the sequence owner, so that thekeys match during replay. Sequence values are kept at replay for manyapplications. The following example sets the KEEP attribute for asequence (in this case, one owned by the user executing the statement;for others, use GRANT KEEP SEQUENCE):

-   -   SQL>CREATE SEQUENCE my_seq KEEP;    -   SQL>—Or, if the sequence already exists but without KEEP:    -   SQL>ALTER SEQUENCE my_seq KEEP;

Note that specifying ALTER SEQUENCE . . . KEEP/NOKEEP applies to theowner of the sequence. It does not affect other users (not the owner)that have the KEEP SEQUENCE object privileges. If NOKEEP is specified,the KEEP SEQUENCE object privilege is not granted to these users (or itis revoked from each if it has been granted to them).

-   -   To keep function results (for named functions) at replay, the        DBA grants KEEP privileges to the user invoking the function.        This security restriction ensures that it is valid for replay to        save and restore function results for code that is not owned by        that user.

The following additional considerations apply to granting privileges onmutable functions:

-   -   If a user has the KEEP privilege granted on mutables values,        then the objects inherit mutable access when the SYS_GUID,        SYSDATE, and SYSTIMESTAMP functions are called.    -   If the KEEP privilege is revoked on mutable values on a sequence        object, then SQL or PL/SQL blocks using that object will not        allow mutable collection or application for that sequence.    -   If granted privileges are revoked between runtime and failover,        then the mutable values that are collected are not applied for        replay.    -   If new privileges are granted between runtime and failover, then        mutable values are not captured and these values are not applied        for replay.        Definitions

A ‘recoverable error” is a class of errors that arise due to an externalsystem failure, independent of the application session logic that isexecuting. Recoverable errors occur following planned and unplannedoutages of foregrounds, networks, nodes, storage, and databases. Theapplication receives an error code that can leave the application notknowing the status of the last operation submitted. Replayre-establishes database sessions and resubmits the pending work for theclass of recoverable errors. The replay driver does not resubmit workfollowing call failures due to non-recoverable errors. An example of anon-recoverable error that would not automatically replay is submissionof invalid data values. Techniques described herein may re-establishdatabase sessions and resubmit pending work for the class of recoverableerrors. Some errors may not be recoverable, and work is not re-submittedfor these errors.

A request is a unit of work submitted from the application to a serverinstance on a database session. The request may include or referencedatabase commands such as SQL and PL/SQL, and other database calls of asingle web request on a single database connection. The request may bedemarcated by the calls made to check-out and then check-in connectionsto the database connection from a connection pool. Replayingre-establishes the transactional and non-transactional state for adatabase session and repeats the request, for recoverable errors.

A “repeatable operation” is a command or set of commands that may berepeated following a recoverable error. For example, an uncommittedtransaction or a non-transactional command may be repeated. Replayingthe set of repeatable operations re-establishes the non-transactionalstate for a database session and may repeat an uncommitted databasetransaction, for recoverable errors. When a request is replayed, theexecution appears to the application and client as if the request wasslightly delayed. The effect may be similar to a loaded system when thedatabase ran the request slightly slower so that the response to theclient is delayed.

In Oracle®, a transaction is committed by updating its entry in thetransaction table. Oracle® generates a redo-log record corresponding tothis update and writes out this redo-log record. Once this redo-logrecord is written out to the redo log on disk, the transaction is deemedcommitted at the database. From the client perspective, the transactionis deemed committed when an Oracle® message (termed Commit Outcome),generated after that redo is written, is received by the client.However, the COMMIT message is not durable. The replay obtains theCommit Outcome available when it has been lost so as to replaytransactions no more than once.

“Non-transactional session state” or “NTSS” is state of the session thatexists outside or apart from the transaction. NTSS can be createdthrough declarative or procedural mechanisms. Examples of declarativemechanisms are attribute settings for MODULE, ACTION, OPTIMIZER_PLAN,NLS_DATE and so on. Examples of procedural mechanisms are PL/SQLprocedures that populate global variables, LOB processing, and AQprocessing. Table 1 lists example states that may be set for applicationusers. Example techniques use an application callback to set the initialstate, and then work through original calls to chronologically build upthe state again.

TABLE 1.2 Example methods for rebuilding Non-Transactional StateClassification Components Recovered at Replay Environment ApplicationInfo Driver sets to last values in use at the time of the outage Module,Action, Client_ID, etc Environment Alter session parameters Rebuild thestate by repeating the execution chronologically Environment SessionParameters Environment Events - Debug Option to resubmit EnvironmentResource Management Set as part of the user settings. Resource usedstarts again Consumer Groups after failover Application PL/SQL Rebuildthe state by repeating the execution Variables chronologically TablesUser defined objects Application AQ Rebuild the state by repeating theexecution Subscription chronologically Application Temporary tableRebuild the state by repeating the execution data survives for durationchronologically of session or transaction Application LOB Rebuild thestate by repeating the execution Duration of TEMP Lob's chronologicallyand recreation when in session duration. Application Cursor StateRebuild the state by repeating the execution At transaction boundaries -chronologically fetch across Commit only Application Result CacheRefresh before returning to capture mode data associated with snapshot

“Mutables” is the term used for functions that may change their resultseach time that they are executed. Mutable functions cause a problem forreplay because the results at replay can change. Considersequence.nextval and sysdate used in key values. If a primary key isbuilt with values from these function calls, and is used in laterforeign keys or other binds, at replay the same function result must bereturned. Application Continuity provides mutable value replacement atreplay for granted Oracle® function calls to provide opaquebind-variable consistency. If the call uses database functions that aremutable including sequence.nextval, SYSDATE, SYSTIMESTAMP, SYSGUID theoriginal values returned from the function execution are saved and atreplay are reapplied.

Session State Consistency

A session has a “static” state if all session state changes (e.g. NLSsettings, PL/SQL package state) occur as part of initialization and canbe encapsulated in a callback at failover.

A session has “dynamic” state if the session state changes are not fullyencapsulated by the initialization, cannot be fully captured in acallback at failover, and are otherwise included in one or more commandsthat execute during the request.

Example Benefits of Restoring Session State

Example benefits may be realized from the various embodiments describedherein, but no particular benefit is guaranteed for any particularembodiment. Other benefits that are not specifically named herein mayalso be realized. Techniques described herein may allow sessionunavailability to be hidden from the end-user and/or the application,whether the session unavailability is planned or unplanned. A stateestablished for the first session may be recovered or restored to thesecond session, even in the presence of customized user environments,in-flight transactions, and/or lost outcomes. The techniques may alsoallow servers to meet target response times for applications regardlessof session outages.

The first server instance may report an outcome of the last transactionto the client or application, and the second server instance may recoverthat outcome followed by the in-flight work. The servers may providesupport to handle outages in the class where no response is receivedfrom the server for a corresponding request to execute commands. Theservers may support session recovery requiring less usage of customizedexception-handling by the application when that session can be replayed.Recovering the session may be useful even if some replay attempts arenot successful. It is true that applications still need to handle errorsfor cases when replay is disabled. However with replay, most failuresshould be masked. This results in fewer calls to the application's errorhandling logic (i.e. less often that the application raises error touser, leaves the user not knowing what happened, or forces the user tore-enter data, or worse that administrators must restart mid-tierservers to cope with the failure, etc.). So overall, replaying shouldgive a better user experience.

Once a user request has been submitted, the user request may be allowedto succeed if the user request can succeed. Following an outage of thedatabase session, the user should not experience the outage if thesession can be replayed. An outage in one part of the system should notreturn an error to the end user or the application. If a transactionfailed and is replayable, the request may be replayed in bounded time.If replay succeeds, the successful return status is returned to theapplication. Outages need not be exposed to the user aftercommunication, system, storage, or site outages even though theseoutages have been exposed in the past.

Users may be able to define a target response time for work, regardlessof outages. Users need not be bothered with lesser service levels foroutages. Business sectors such as banking, telecommunications, stocktrading, manufacturing, transport, and retail may not tolerate degradedresponse times, regardless of the underlying reason. Degraded responsetimes may create a competitive disadvantage that is not acceptable.According to various techniques described herein, servers may maskserver-side outages from the client, avoiding replay of commands beyonda time threshold to avoid unexpected results.

Example Server-Client Systems for Executing Requests

Many database management systems (“DBMS”) provide a transaction-basedprogramming model to application programmers through various clientdriver interfaces, such as an Oracle Call Interface (“OCI”) driver orJava Database Connectivity (“JDBC”) driver. Through the drivers,executing the top-level SQL and PL/SQL calls builds the transactionstate and non-transactional state of the database session. The clientdriver may send SQL and PL/SQL calls to the DBMS, and, at the end of thetransaction, the changes are committed or rolled back. FIG. 1 showsdifferent components and layers of an example server-client system. Inthe example, the client driver sends SQL and PL/SQL calls to the DBMSand, at the end of the transaction, the changes are committed or rolledback. As shown, non-transactional and transactional states are built upfor the database session, and transactional states are cleared ascommits are completed for corresponding transactions.

When using a connection pool, the unit of work is a request. The requestcomprises check-out from the connection pool, SQL and PL/SQL calls andusually zero or one COMMIT operation. The request ends when theapplication releases the connection back to the pool. Replay is enabledat the beginning of the request and is disabled at the end of therequest. If an outage occurs, replay repeats the request, unless replayhas been disabled by a commit if in dynamic mode, or an explicit disablereplay application programming interface (API) used by the applicationfor some requests.

In the example of FIG. 1, optionally, if stripes and tags were not fullyset, the connection manager sets the stripes and tags for theapplication. An application signals the beginning of a request, eitherby checking a connection out from a connection pool or by sending acommand that conforms to an application programming interface formarking request boundaries. At the beginning of a request, replay isenabled, and capture under the direction of the database begins. Theclient sends SQL or PL/SQL to the RDBMS that does not involvetransactions. The SQL engine compiles each statement and sends therequest to the SQL engine or PL/SQL engine. Executing statements buildsup the non-transactional states for the session at the server. Theserver returns a result set, output binds, DML returning results,function results, and other messages to the client. While replay isenabled, the server piggyback's directives for enqueuing or purging thereplay plus the replay context for validating and securing the replay ifneeded. Some of the results will be held in the client driver and usedby the application in its decision making. The client sends a SQL thatstarts a transaction or PL/SQL containing one or more transactions tothe RDBMS. The SQL engine compiles each statement and sends the requestto the PL/SQL engine (if PL/SQL) and to the DML driver. This builds uptransactional state and further non-transactional state for the databasesession. The result of the operation including any error message isreturned to the client driver. Again, while replay is enabled, theserver piggyback's directives plus the replay context. The client sendsa commit request to the RDBMS, or the client has set auto-commit thatencompasses this request or the PL/SQL has embedded COMMIT. The SQLengine compiles the statement and sends the commit request to thetransaction layer. The transaction layer flushes the change records todisk. The success of committing is built post commit and is returned tothe client. While replay is enabled, the server piggyback's directivesplus the replay plus the replay context. With the COMMIT outcome, theclient also receives the next logical transaction identifier (LTXID)that will be used piggybacked on the commit outcome.

The client driver sends a SQL or PL/SQL command to the server andreceives the result set error handle containing any error messages,piggybacked directives for replay and replay context. This informationis held in memory at the client driver. The application results areforwarded to the application for processing. The application may cachethe results and bind values, and continue to use these in futureprocessing of the subsequent queries and transactions. The replaydirectives are followed by the client driver. The SQL or PL/SQL commandand replay context may be held based on the directives.

Without the techniques described herein, if the client entered work andsubmitted the work to the server, the client expects a present state,potentially with entered data, returned data, and variables cached. Ifthere is an outage due to unavailability of a server-side component or afailed connection between the server and the client, thenon-transactional session state that the application needs to operatewithin would have been lost. If a transaction had been started andcommitted and had not been issued, the in-flight transaction would berolled back and would need to be re-submitted by the client. If atransaction had been started and one or more commits had been issued,the commit message that is sent back to the client is not durable. Inother words, the client is left not knowing whether the requestcommitted or not, and where in the non-transactional processing statethe commands reached during execution.

To accommodate outages, an application could be modified to includecustom code for re-connecting, re-establishing non-transactional sessionstate, querying the server to determine what was being executed at thetime of failure, and then determining if the work was committed or needsto be repeated. However, any application code module can fail, anddeveloping custom code on an application module-by-module basis toexecute error handling would be prohibitively expensive. Also, in thisscenario, there would be nothing general for the client to query todetermine whether a transaction has committed or not. Custom checkswould probably not accommodate local transactions, distributedtransactions, parallel transactions, replicated transactions, andextended architecture or global (XA) transactions. Further, the checkedoperation can complete after the check is made by the client, and theclient could not rely on a result of a client-side check so such asolution is not safe to use.

If a lost transaction is submitted again, a server-client system couldpreserve atomicity and consistency. The transaction cannot be validlyresubmitted if the non-transactional state is incorrect or if it alreadycommitted. The transaction cannot be automatically resubmitted if thedatabase has been restored to an earlier point in time, or is apartially replicated copy of the original that no longer containsdeciding data.

This embodiment rejects the replay if the database that is used forreplaying is a different database, or is the same database but thedatabase has lost committed transactions. This embodiment automaticallydetermines which databases are legal for replay and which are not. Thisembodiment can account for standalone databases and consolidateddatabases. It allows replay from a standalone database to the samedatabase plugged into a consolidated database, and when unplugging adatabase from one consolidated database and plugging it into another.The embodiment always rejects replay if an attempt is made to replayagainst a different, potentially divergent database.

Example Server-Client Systems for Masking Database Outages

In one embodiment, the Application Continuity architecture defines aprotocol between the application and the database such that thetransactional and non-transactional database session states are rebuiltif the database session becomes unavailable. When the database sessionbecomes unavailable, is relocated, or becomes unresponsive, the replaydrivers, in collaboration with the database, attempt to rebuild theaffected database sessions. States at the application or mid-tier havenot failed, so the database sessions are rebuilt to where they werebefore the failure, optionally, validating that client visible resultsof the application recovery match the pre-outage results as replayprogresses and at replay completion.

In one example, when a request times out waiting for a reply and isresubmitted or if the user becomes impatient and resubmits, the replayblocks earlier sessions. The original submission is detected and themost recent one request is committed, any others in-flight for the samerequest are rejected and roll back.

FIG. 3 shows an example architecture and component placement for theclient-driver replay (termed Replay Driver) and WebLogic Server basedreplay. The figure shows the placement for example components that havebeen configured to deliver replay capabilities. An example server,Oracle 12g RDBMS, manages continuity of database sessions so that thedatabase sessions remain uninterrupted even during an outage of a serverinstance that served the session. During runtime, the server sendsreplay context and LTXIDs to the client driver (for example, a JDBCReplay Driver or an Oracle Call Interface Transparent ApplicationFailover (OCI TAF) module as shown), and the client driver holds theLTXIDs and the replay context in case replay is needed. If replay isneeded, under the direction of the database, the client driver resubmitseach command. The database uses the LTXID to determine if the lastrequest committed, and, if it did not, blocks it from doing so. Thedatabase uses the replay context first to validate the security,database, protocol and execution environment at the second session.After replay, the database uses the replay context to check that theuser visible results are the same as those from the original execution,and that the execution environment has been rebuilt correctly. Replayprogresses with the server validating the fidelity of each replay usingthe replay context. This process allows the replay driver and server tocollaborate restoring the transactional and non-transactional on asecond session, if the first server becomes unavailable. The replay maybe repeated on a third or fourth session continuing until the replaysucceeds. If replay succeeds, the process returns to capturing therequest again. If replay is not possible, the original error is returnedto the application or client together with the known outcome committedor not.

Sample Architecture Components

The following components of Application Continuity may work together toexecute capture and replay:

The replay drivers intercept execution errors and, when these errors arerecoverable, automatically replay the user calls from the beginning ofthe request. When successful, the replay appears to the application as adelayed database interaction.

In collaboration with the database, the replay drivers maintain ahistory of calls during a conversation between a client and thedatabase. For each call made at run time, the driver retains the contextrequired for a subsequent replay.

The continuity director directs the run time and replay, collaboratingwith the replay drivers as to what. The director knows what isrepeatable and how it should be repeated, and applies this knowledge asfollows:

During run time, saving protocol and validation information (andmutables sufficient for replaying), or directing the replay drivers tokeep or purge calls

During replay, rejecting a replay that:

-   -   Runs on a different database or a database that has lost        transactions and potentially diverged    -   Violates protocols    -   Fails to reproduce the same client-visible data (rows, out        binds, error codes, and messages) that the application or client        saw and potentially made decisions on during the original        execution

The replay context is opaque information that the database returns tothe client driver during normal application run time. The replay driverssave the context with each SQL or PL/SQL call that the drivers have beeninstructed to hold. The replay context contains sufficient knowledge toprotect and validate replay of each call, and to apply mutables whenmutable values have been retained. When a call is no longer needed forreplaying the session, the replay context is discarded along with thecall itself.

Example Replay Drivers

The JDBC Replay Driver and OCI Transactional Application Failover (bothreferred to here as Replay Drivers) are example components ofApplication Continuity for replaying lost work following recoverabledatabase outages.

The Replay Drivers maintain a history of calls during a clientconversation with the database, as instructed by the ContinuityDirector. Each replay driver maintains queues of calls, and for eachcall kept at runtime keeps the Replay Context needed for a later replay.The replay duration is limited by releasing accumulated history at endof request (normally, check-in to a driver pool), when replay isexplicitly disabled, and at identified end of requests. A Replay Driverrecords the call history for the duration of each request, purgingclosed calls for completed requests, and SELECT calls and completedtransactions for applications that are identified to not changenon-transactional session state during a request, under the direction ofthe Continuity Director. In another implementation the retained historyis marked for release during a request, and releases occur at the end ofrequest or as needed by the garbage collector.

Following any outage of the session that is due to a loss of databaseservice, planned or unplanned, the replay drivers rebuild thenon-transactional and transactional database session states. A replaydriver establishes a new session, so that there is no residual state,issues an optional callback allowing the application to re-establishinitial state for that session (if the callback is registered), and thenre-executes the saved call history accumulated during runtime. Thereplay of calls comes from driver queues and can be repeatedchronologically or in a lazy fashion depending on how the applicationchanges the database state. The replay is under the direction of theContinuity Director component. Each replayed call may be checked toensure that it returns exactly the same client visible state that wereseen and potentially used by the application in its decision making atthe original execution. Each replayed call may also be checked todetermine whether the call passes pre-replay and post-replay checks atthe database in order for the replay to be accepted and finalized.

In one embodiment, replay protects the consistency of SQL and PL/SQLstatements (including within transactions) by passing the Replay Driversthe original mutable values in an opaque context area, called the Replaycontext, during the original execution of each database operation. TheReplay context is saved by the Replay Drivers with the method callcorresponding to the database operation, and is returned to the databaseserver with each matching database operation during the replay. TheReplay context is used to restore the original values of transient SQLfunction results when that function call is made at the server-side.Using this mechanism, original values are restored ensuring that theoriginal value is used in the replayed query and the same values arereturned as the result of the query. This occurs with minimum cost tothe Replay Drivers.

At-most-once transaction execution is protected by the LTXID.Transactions are only resubmitted when the error is recoverable and theoutcome for the transaction is confirmed as not committed by the lastLTXID that was in use. The LTXID on the session that has been replacedat replay is now the LTXID that is in effect for the request. If the newsession fails, then the latest LTXID in use is that which is checked for“at-most-one execution”. All others have been blocked by previous replayattempts.

The Continuity Director, using the information in the Replay context,rejects the replay if there is any mismatch in outcome. This includesall data that is returned on the wire including out binds, DMLreturning, error codes and error messages. This rejection ensures thatall data that the application potentially made decisions upon arere-established—namely, rows are returned in the same order as theoriginal execution, that the outcomes—in out binds (e.g. DML returningand PL/SQL procedure and function results, error codes and errormessages) and row sets are the same as the original execution, and thatSQL defines, in-binds, and execution environment are the same as theoriginal execution. Any divergence results in the replay being aborted,and if in a transaction, that transaction is rolled back. Thefailed-over session and session state (apart from the transaction) areleft as is, allowing the application to take its own recovery action. Inone embodiment, the responsibility of validation is moved to the clientside when the Replay Context is not available.

The Replay Drivers may record the history for the duration of therequest, purging closed method call for completed queries and closedtransactions if operating in static mode, or if state is known not tohave changed in the transaction or not to be relied on in after thetransaction when operating in dynamic mode. The replay duration islimited by purging closed cursors after SELECT calls have completed ifthose SELECT statements did not change state, if replay has beendisabled, and at the end of the request.

Example features provided below are integrated with the Replay Driversto support a correct replay with acceptable cost to runtime performance.

Example Continuity Director

In one embodiment, a Continuity Director causes the database server todirect the runtime and replay parts of the feature. The objective is forthe database server to collaborate with the client-side replay driversas to what to do. This has the possible advantages that thedecision-making is in one place for all replay drivers, the decision isin a place that has access to the information (such as non-transactionalstate changes, embedded and top-level commits, rollback, administrativecalls etc), and that place is extensible for all replay drivers. In oneembodiment, the logic for handling replayable patterns, for what thereplay drivers place in their queues, and when to purge, exists in thedatabase server. In other embodiments, the logic may be distributedamong several components of the database system or may exist on anentirely different component of the database system. For example, thereplay drivers let the Continuity Director know where requests begin andend, when input streams cannot be rewound and so replay is disabled, andwhen the application executes an explicit disable replay API.

The Continuity Director solution encapsulates the knowledge regardingwhat is repeatable, rather than what is not repeatable. In oneembodiment, information indicating what is playable is a white list ofreplayable items rather than a black list of non-replayable items. Thisknowledge is applied at runtime by the Continuity Director to direct theclient drivers to keep or purge calls, and at replay to reject replaythat is to a divergent database, violates protocols, or does notreproduce agreed states (amongst other things). The Continuity Directorworks in unison with the replay context at runtime to save securitycredentials, database signature, stateful-ness information, cursorenvironment, execution system change number (SCN), and the checksum forclient visible results. These data are used to determine whether replaywill be allowed, and if replay is allowed whether that replay is valid.At replay, the cursor environment and execution SCN are re-establishedor validated for each call using the information held in the replaycontext for that round trip.

The continuity director layer is placed in the RDBMS' call processingmanagement layer. This allows a complete picture of calls into and outof the database to the replay drivers.

Examples of Purging Information

In order to conserve memory consumption, the Replay Drivers may purgerecorded calls that are no longer needed for replay. Applications mayproperly and timely close ResultSets and Statements following use, viastandard JDBC and OCI calls.

The JDBC and OCI Replay Drivers would purge stored call history and allreplay-specific objects (such as in-binds, replay context) that arerelated to a Call (including PreparedStatement and CallableStatement),when that Statement is closed and there is no bounding activetransaction, and that statement made no changes to the databasenon-transactional session state and on request end, when that connectionis returned to the pool.

The Replay Drivers will also provide a History-Purging API that allowsapplications to purge the stored call history that has been marked forrelease within the Replay Drivers prior to the purge point. This helpsto further conserve memory consumption, in case applications do not ordo not timely close Result Sets and Statements or keep using the sameconnections for an extended period of time without returning them to thepool. This API only purges stored operation history that has been markedfor release. It does not involve altering a connection's state byre-executing any JDBC method, SQL, or PL/SQL. It does not purge historythat has not been marked for release.

Example Replay Context

In one embodiment, the security, and consistency of the database sessionis protected at replay by passing to the Replay Drivers, during theoriginal execution of each top-level call, an opaque context area calledthe Replay Context. The Replay Context is saved by the Replay Driverswith the queued SQL or PL/SQL call corresponding to the top-leveldatabase operation. The replay context is returned to the databaseserver with each matching database operation during a replay.

The replay context carries the knowledge to validate the security,compatibility, validity, correctness of replay, and to optimize thereplay. The replay context may contain the mutable values that were usedfor original function executions, the checksum for data exposed to theapplication, a protocol checksum for security and protocol validation,the keys for transactional result sets, and the optimizers' executionplan. Most of the time, the replay context contains the databasesignature, scn, checksum and protocol checksum only. The replay contextmay be provided to the replay drivers as a whole or as a delta of thelast starting from the beginning of the request

In one embodiment, an instance of the replay context may contain somecombination of the following knowledge to support replay/migration ofin-flight work.

Database signature for determining the relative point in time of thedatabase at the time that the original call executed (DBID, DBINC,timestamp, consolidated database SCN).

Ownership, transaction signature (LTXID), and call order to protectagainst tampering with the replay and against protocol violations—bugsor intentional.

SCN to optimize replay when browsing at original database.

Checksum of visible results that were sent to the client on firstexecution. The database-based checksum offloads checksum calculationfrom the client-drivers and provides immediate database-side rejectionat mismatch at replay. The checksum may take advantage of hardware—basedcalculations when these are available. The checksum algorithm iscompatible between hardware and software, and across ports and versionsto support failover and migration of database sessions.

Output for selected ORACLE function calls to support visible resultconsistency (termed mutable support).

Version related tuples to provide detection of LOB/BLOB/CLOB and Securefile changes for media types that rarely change, avoiding the process ofscanning and creating checksums on Gigabytes of large object data.

DBID-Rowid-Row version tuples to provide opaque optimistic locking intransaction replay.

Optimizer execution plan to safeguard output order for SELECT replaywhen ORDER BY is not part of the original SQL statement.

In one embodiment, the replay context uses universal format to handleendian, version, and port changes between original and failover target.

The Continuity Director uses the replay context to support security, andcorrectness of the replay. When replay is enabled, the Replay Context isreturned as an opaque object to the client with every call. The replayis rejected if there is a mismatch outcome, after applying any mutablevalues and SCN, and after comparing the checksums accrued for the clientvisible results against that for the original call (contained in thereplay context). The validation includes—that rows are returned in thesame order as the first submission for the portion of the row set thatthe application has seen; that the outcomes in out binds (e.g. DMLreturning and PL/SQL procedure and function results and error codes andmessages) are the same; and that row sets size and any error codes arethe same as the original submission. Divergence results in the replaybeing aborted, and if in a transaction, that transaction is rolled back.

Example Transaction Idempotence Component

The Continuity Director uses transaction idempotence in order to preventduplicate transactions. During normal runtime, an LTXID is automaticallyheld in the session at both the client and server. At commit, the LTXIDis persisted as part of committing the transaction, and an updated LTXIDis returned to the client.

At replay for each session failing over, the Continuity Directorreceives the last LTXID in-use for that session and, if that call hadthe capability to commit information, calls a FORCE_OUTCOME api todetermine the outcome of the last call on that session. TheFORCE_OUTCOME call may involve blocking the LTXID from committing sothat the outcome is known and cannot be duplicated by an in-flighttransaction (i.e., a transaction still executing on another server).Blocking the LTXID from committing supports replay fidelity should atransaction using that LTXID be in flight. GET_LTXID_OUTCOME thatinternally calls FORCE_OUTCOME is called before attempting driver-basedor Web-Logic Server-based replays, to prevent multiple executions of asingle transaction.

As an optimization, FORCE_OUTCOME, or GET_LTXID_OUTCOME, is not calledif the last call from the session that died could not execute a commit.For example, the last call was a SELECT, or an INSERT, UDATE or DELECTwith auto-commit mode not set, or the session that died was operatingagainst a read-only service or database.

The transaction idempotence component delivers integrated functionalitythat provides the idempotence automatically and transparently toapplications. In one embodiment, the transaction idempotence componentincludes some combination of the following features.

Durability of COMMIT outcome by saving a LTXID at COMMIT for alltransaction types against database. This includes idempotence fortransactions executed using auto-commit, from inside PL/SQL, from insideserver side Java, from remote and distributed transactions and fromcallouts that cannot otherwise be identified using generic means.

Using the LTXID to support at-most-once execution semantics such thatdatabase transactions protected by LTXIDs cannot be duplicatedregardless of whether there are multiple copies of that transaction inflight.

Blocking COMMIT of in-flight work to ensure that regardless of theoutage situation, another submission of the same transaction for exampleby a browser or mid-tier cannot commit.

Identifying whether work committed at a LTXID was committed as part of atop-level call (client to server), or had other complexities, such as(a) being embedded in a procedure such as PL/SQL or Java at the server,or (b) being in a call that may have had other results or effects thatmay have been lost. An embedded commit state indicates that while acommit completed, the entire procedure in which the commit executed maynot have run to completion. Any work beyond the commit cannot beguaranteed to have completed until that procedure itself returns to thedatabase engine, and the client cannot find out unless those resultsreached the client or were known and persisted with the transactionoutcome.

Identifying if the database to which the COMMIT resolution is directedis ahead of, in-sync, or behind the original submission and rejectingwhen there are gaps in the submission sequence of transactions from aclient. It is deemed an error to attempt to FORCE idempotence if theserver or client are not in sync in transaction order as determined bythe LTXID sequence.

A callback on the client driver that fires when the LTXID is incrementedby a call from the client to the server. This is used to access theLTXID for higher layer applications such as WebLogic and third partiesin order to maintain the current LTXID ready to use to block duplicatesubmissions.

Namespace uniqueness across globally disparate databases and acrossdatabases that are consolidated into a pluggable infrastructure. Thisincludes RAC, Data Guard, Golden Gate, and Pluggable Databases.

Example Methods for Masking Database Outages

FIG. 1 shows an example server-client workflow for recording work atreplay driver level, directing the driver, managing replay context, andachieving transaction idempotence. The flow shows query and transactionhandling. Replay is available, unless it has been explicitly orimplicitly disabled, between begin request and end request.

FIG. 2 shows an example server-client workflow for failover for adatabase system driven by Continuity Director, Replay Driver andidempotence protocols for achieving at-most once execution oftransactions.

In order to recover an application session from a database serveroutage, the conversation for that session is replayed from the beginningof the request based at least in part on the status of the session'sconversation at the time of the outage. For example, the applicationsession may be reading outside a transaction, in a transaction,completing a transaction with commit or rollback. The server-clientsystem is able to re-establish the non-transactional state such as NLSattributes, transactional state, PL/SQL package globals, etc. to wherethey were at the time of the outage. The server-client system is alsoable to re-execute a transaction in the right environment, if thetransaction was in-flight and did not commit. The server is able torestore mutable function values if these have been permitted.

To minimize impact on the application, the replay driver attempts to putthe database session back to where it would have been had the originalexecution been delayed. The approach to replay is to first determine thestatus of the in-flight transaction in that database session if thattransaction could have committed at the time of the outage. Then, oncethe status of the in-flight conversation is known, to resume theapplication from a consistent state in which the components such as thebrowser, application, mid-tier, database driver, and database sessionare aligned.

Replay includes determining the last committed status of that session ifcommit was possible. The last part of the conversation may have been asimple top-level call such a DML, COMMIT, or a PL/SQL block that startedand potentially executed one or more COMMITs. The LTXID is the key tothis step. The last used LTXID is passed in a Prepare_Replay call to theserver. At runtime the server has kept a record of transactions executedfor that LTXID. The first step of replay is to obtain a new session (newso that the state is clean) and to use the LTXID and last SQL or PL/SQLcall to ascertain the conversation status at the outage. If that lastSQL or PL/SQL call could not have committed then this step returns anuncommitted status.

Once the status is known, if a callback has been registered, the nextstep is to allow the application to restore basic end user state, suchas NLS settings, security attributes, etc., that are more or lessconstant across requests from the same end user. This step is used whenusing static state, where state is established at the beginning. It isoptional when using dynamic state, but using callouts, such as UCPlabeling to set the state does provide better performance as there is noneed to re-establish state at the start of every request. When acallback is registered it may be executed at runtime and at a replay, orat replay only depending on its implementation.

Subsequent steps re-execute the calls that created the session state andtransaction state (if there was a transaction). These steps replay thecalls of the current request, or that subset of calls necessary torestore the most recent session state and transactions state, e.g. thecalls of the current transaction, but not those of previous transactionsor requests. The replay of each call is supported by the replay contextthat is used to validate the database incarnation, protocol (aka replayis in correct order), outcomes, to restore values for ORACLE functionsthat would otherwise lead to mismatches at replay, to optimize thereplay, and to validate the environment.

Example Rules for Replaying when PL/SQL is Present

In one embodiment without support for idempotence, when a Replay Driversees a transaction started or the last call is PL/SQL at the top-level,recording of history ceases and the recording history is purged. This isbecause that PL/SQL could commit a transaction.

In one embodiment with support for PL/SQL replay in current mode, replayswitches to current mode once PL/SQL has been seen and no longer usesSCN because it is not valid to go backwards in time.

Applications may execute and commit transactions for connectioninitialization. So long as the transaction is committed in the callback,this is valid to replay.

For non-transactional state, history is held for calls executed that didnot result in the transaction bit (aka. non-transactional) being setfollowing execution. Before PL/SQL is seen, while replaying SELECTstatements, the replay driver uses consistent mode—replaying “as of” theoriginal SCN. This is an optimization to minimize rejection rate due tocurrent mode. The optimization supports new modules written to bedatabase independent.

If the replay driver reaches top-level PL/SQL, replay ceases usingoriginal SCN and all subsequent calls, SELECT and PL/SQL run in currentmode. The behavior is as if the submission is delayed. SELECT calls maynot be purged at runtime, even if closed once in current mode replay.Replay re-executes and then closes previously closed cursors again.Purge at end of http request and at transaction close is unchanged. Inthis read-only solution, at replay, COMMIT may be disabled for all callsexcluding the last call made.

With idempotence supported automatically by Transaction Guard, fortransactional state, recording may continue beyond the non-transactionalphase, through the transaction until COMMIT is successful. Once in atransaction, SELECT, DML, and PL/SQL always execute in current mode. Ifthe transaction did not commit, whether Pl/SQL is present or not, thereplay driver can play through, with the transaction in current mode.DML and PL/SQL executes at current mode. After a successful COMMIT, ifusing dynamic state, and state was changed in a committed transaction,for example by PL/SQL, then replay is disabled for that request andremains disabled until the next request begins. After a successfulCOMMIT when using dynamic state, replay is disabled and all history,excluding Open cursors, outside transactions is purged. Conversely, ifusing static state, the application has stated or it has been detectedthat it does not change state after setup or changes state and thisstate is not relied on after commit. In which case, just thattransaction is purged, and replay stays enabled until the request ends.

During replay, COMMIT may be disabled for all calls excluding the lastcall made. This is to avoid commit boundaries changing during thereplay. Before the last call, COMMIT is re-enabled. The last call didnot return to the client, so the client has not made a decision based onit. It did not already commit because they has been verified by theLTXID processing.

In one embodiment, history recording resumes at next begin requestmarker. Both eBusiness Suite (when marked as able to lose theconnection) and Fusion Applications UI operations are examples ofapplication s that are stateless between requests but continue to holdthe physical connection. For connection pools, the ORACLE poolsimplicitly mark the beginning and end of requests at check-out andcheck-in respectively. This tells the replay drivers when to enablereplay and to start recording, and when to disable replay and stoprecording. New published API's beginRequest and endRequest allow otherthird party connection pools to mark requests at check-in and check-out.Standalone applications can to mark where requests begin and end usingthese APIs.

When replay occurs, the entire request is replayed up to where theoutage occurs, and then continues with the remainder of the request. Theexecution appears to the user, application and client as if the requestwas slightly delayed. The effect is similar to a loaded system when thedatabase ran the request slightly slower so that the response to theclient is delayed. In one embodiment with support for PL/SQL replay inconsistent mode, non-transactional state is maintained for callsexecuted that did not result in the transaction bit being set. Whilereplaying SELECT statements, the replay driver uses consistentmode—replaying ‘as of’ the original SCN. If the replay driver reachestop-level PL/SQL that is non-transactional (i.e., did not open atransaction at original execution), replay sets the session SCN to theoriginal SCN, and replays that PL/SQL and its children at that SCN.

For transactional state, recording and replay may continue through thetransaction phase until COMMIT. All calls in a transaction, SELECT, DML,and PL/SQL are replayed at current SCN. If the transaction did notcommit, whether Pl/SQL is present or not, the replay driver can playthrough, with the transaction in current mode. DML and PL/SQL executesat current SCN. After a successful COMMIT, if the replay is determinedto be using dynamic state, then replay may be disabled when that COMMITsucceeds. Once disabled, replay remains disabled until the end of therequest. This is not a significant problem because most requests containzero or one commit, and that COMMIT, when present, is often immediatelyfollowed by an end request and check-in back to the connection pool.When there is a state change, some solutions can detect that this statechange is not relied on after the transaction commits. If a state changeis detected in a committed transaction and is relied on, a third set ofcommands could be maintained to re-establish that state. The solutionreplays past COMMIT if determined to be using static state.

Hardware Overview

According to one embodiment, the techniques described herein areimplemented by one or more special-purpose computing devices. Thespecial-purpose computing devices may be hard-wired to perform thetechniques, or may include digital electronic devices such as one ormore application-specific integrated circuits (ASICs) or fieldprogrammable gate arrays (FPGAs) that are persistently programmed toperform the techniques, or may include one or more general purposehardware processors programmed to perform the techniques pursuant toprogram instructions in firmware, memory, other storage, or acombination. Such special-purpose computing devices may also combinecustom hard-wired logic, ASICs, or FPGAs with custom programming toaccomplish the techniques. The special-purpose computing devices may bedesktop computer systems, portable computer systems, handheld devices,networking devices or any other device that incorporates hard-wiredand/or program logic to implement the techniques.

For example, FIG. 6 is a block diagram that illustrates a computersystem 600 upon which an embodiment of the invention may be implemented.Computer system 600 includes a bus 602 or other communication mechanismfor communicating information, and a hardware processor 604 coupled withbus 602 for processing information. Hardware processor 604 may be, forexample, a general purpose microprocessor.

Computer system 600 also includes a main memory 606, such as a randomaccess memory (RAM) or other dynamic storage device, coupled to bus 602for storing information and instructions to be executed by processor604. Main memory 606 also may be used for storing temporary variables orother intermediate information during execution of instructions to beexecuted by processor 604. Such instructions, when stored innon-transitory storage media accessible to processor 604, rendercomputer system 600 into a special-purpose machine that is customized toperform the operations specified in the instructions.

Computer system 600 further includes a read only memory (ROM) 608 orother static storage device coupled to bus 602 for storing staticinformation and instructions for processor 604. A storage device 610,such as a magnetic disk, an optical disk, or a solid-state drive, isprovided and coupled to bus 602 for storing information andinstructions.

Computer system 600 may be coupled via bus 602 to a display 612, such asa cathode ray tube (CRT), for displaying information to a computer user.An input device 614, including alphanumeric and other keys, is coupledto bus 602 for communicating information and command selections toprocessor 604. Another type of user input device is cursor control 616,such as a mouse, a trackball, or cursor direction keys for communicatingdirection information and command selections to processor 604 and forcontrolling cursor movement on display 612. This input device typicallyhas two degrees of freedom in two axes, a first axis (e.g., x) and asecond axis (e.g., y), that allows the device to specify positions in aplane.

Computer system 600 may implement the techniques described herein usingcustomized hard-wired logic, one or more ASICs or FPGAs, firmware and/orprogram logic which in combination with the computer system causes orprograms computer system 600 to be a special-purpose machine. Accordingto one embodiment, the techniques herein are performed by computersystem 600 in response to processor 604 executing one or more sequencesof one or more instructions contained in main memory 606. Suchinstructions may be read into main memory 606 from another storagemedium, such as storage device 610. Execution of the sequences ofinstructions contained in main memory 606 causes processor 604 toperform the process steps described herein. In alternative embodiments,hard-wired circuitry may be used in place of or in combination withsoftware instructions.

The term “storage media” as used herein refers to any non-transitorymedia that store data and/or instructions that cause a machine tooperation in a specific fashion. Such storage media may comprisenon-volatile media and/or volatile media. Non-volatile media includes,for example, optical disks, magnetic disks, or solid-state drives, suchas storage device 510. Volatile media includes dynamic memory, such asmain memory 506. Common forms of storage media include, for example, afloppy disk, a flexible disk, hard disk, solid-state drive, magnetictape, or any other magnetic data storage medium, a CD-ROM, any otheroptical data storage medium, any physical medium with patterns of holes,a RAM, a PROM, and EPROM, a FLASH-EPROM, NVRAM, any other memory chip orcartridge.

Storage media is distinct from but may be used in conjunction withtransmission media. Transmission media participates in transferringinformation between storage media. For example, transmission mediaincludes coaxial cables, copper wire and fiber optics, including thewires that comprise bus 602. Transmission media can also take the formof acoustic or light waves, such as those generated during radio-waveand infra-red data communications.

Various forms of media may be involved in carrying one or more sequencesof one or more instructions to processor 604 for execution. For example,the instructions may initially be carried on a magnetic disk orsolid-state drive of a remote computer. The remote computer can load theinstructions into its dynamic memory and send the instructions over atelephone line using a modem. A modem local to computer system 600 canreceive the data on the telephone line and use an infra-red transmitterto convert the data to an infra-red signal. An infra-red detector canreceive the data carried in the infra-red signal and appropriatecircuitry can place the data on bus 602. Bus 602 carries the data tomain memory 606, from which processor 604 retrieves and executes theinstructions. The instructions received by main memory 606 mayoptionally be stored on storage device 610 either before or afterexecution by processor 604.

Computer system 600 also includes a communication interface 618 coupledto bus 602. Communication interface 618 provides a two-way datacommunication coupling to a network link 620 that is connected to alocal network 622. For example, communication interface 618 may be anintegrated services digital network (ISDN) card, cable modem, satellitemodem, or a modem to provide a data communication connection to acorresponding type of telephone line. As another example, communicationinterface 618 may be a local area network (LAN) card to provide a datacommunication connection to a compatible LAN. Wireless links may also beimplemented. In any such implementation, communication interface 618sends and receives electrical, electromagnetic or optical signals thatcarry digital data streams representing various types of information.

Network link 620 typically provides data communication through one ormore networks to other data devices. For example, network link 620 mayprovide a connection through local network 622 to a host computer 624 orto data equipment operated by an Internet Service Provider (ISP) 626.ISP 626 in turn provides data communication services through the worldwide packet data communication network now commonly referred to as the“Internet” 628. Local network 622 and Internet 628 both use electrical,electromagnetic or optical signals that carry digital data streams. Thesignals through the various networks and the signals on network link 620and through communication interface 618, which carry the digital data toand from computer system 600, are example forms of transmission media.

Computer system 600 can send messages and receive data, includingprogram code, through the network(s), network link 620 and communicationinterface 618. In the Internet example, a server 630 might transmit arequested code for an application program through Internet 628, ISP 626,local network 622 and communication interface 618.

The received code may be executed by processor 604 as it is received,and/or stored in storage device 610, or other non-volatile storage forlater execution.

In the foregoing specification, embodiments of the invention have beendescribed with reference to numerous specific details that may vary fromimplementation to implementation. The specification and drawings are,accordingly, to be regarded in an illustrative rather than a restrictivesense. The sole and exclusive indicator of the scope of the invention,and what is intended by the applicants to be the scope of the invention,is the literal and equivalent scope of the set of claims that issue fromthis application, in the specific form in which such claims issue,including any subsequent correction.

What is claimed is:
 1. A method comprising: a server instance receiving,from a client in a session between the server instance and the client, arequest to execute: one or more transactional commands that, whenexecuted, cause changes to a database, and one or more non-transactionalcommands that, when executed, do not cause changes to the database; theserver instance sending, to the client, at least one first directiveinstructing the client to store one or more first items representing oneor more particular transactional commands that are open but not yetcommitted in the session in a first set of information and to store oneor more second items representing one or more particularnon-transactional commands that have been processed in the session in asecond set of information; determining that the one or more particulartransactional commands have committed in the session; and based at leastin part on determining that the one or more particular transactionalcommands have committed in the session, the server instance sending, tothe client in the session, at least one second directive instructing theclient to purge, from the first set of information, the one or morefirst items that represent the one or more particular transactionalcommands without purging, from the second set of information, the one ormore second items that represent the one or more particularnon-transactional commands; wherein the method is performed by one ormore computing devices.
 2. The method of claim 1, further comprising:determining that the request has completed in the session; based atleast in part on determining that the request has completed in thesession, the server instance sending, to the client in the session, athird directive instructing the client to purge, from the second set ofinformation, the one or more second items that represent the one or moreparticular non-transactional commands.
 3. The method of claim 2, whereinthe third directive instructs the client to purge, from the first set ofinformation, the one or more first items that represent anytransactional command.
 4. The method of claim 1, wherein the at leastone first directive comprises at least one directive instructing theclient to store, in the second set of information, the one or moresecond items that represent the one or more particular non-transactionalcommands.
 5. The method of claim 4, further comprising: determining thatthe particular one or more non-transactional commands have beenprocessed in the session; based at least in part on determining that theparticular one or more non-transactional commands have been processed inthe session, the server instance sending, to the client in the session,one or more directives instructing the client to maintain, in the secondset of information, the one or more second items that represent the oneor more particular non-transactional commands.
 6. The method of claim 1,wherein a first data structure is used to store the first set ofinformation is stored; and wherein a second data structure is used tostore the second set of information.
 7. The method of claim 6, whereinthe first data structure is a first queue and the second data structureis a second queue.
 8. The method of claim 1, wherein the session has astatic state indicating that session state changes for the session occuras part of session initialization or outside of any transaction; andwherein the server instance sends the at least one second directive inresponse to committing any transaction in the session.
 9. The method ofclaim 1, further comprising: detecting that a transaction in the requestsets a non-transactional session state; determining whether latercommands in the request use the non-transactional session state; if itis determined that later commands do not use the non-transactionalsession state, after committing the transaction, the server instancesending, to the client in the session, at least one directiveinstructing the client to purge, from the first set of information andthe second set of information, the one or more first items thatrepresent the one or more particular transactional commands and the oneor more second items that represent the one or more particularnon-transactional commands; and if it is determined that later commandsuse the non-transactional session state, after committing thetransaction, the server instance sending, to the client in the session,a directive instructing the client to purge, from the first set ofinformation, the one or more first items that represent the one or moreparticular transactional commands.
 10. The method of claim 1, furthercomprising: the server instance detecting that one or more transactionsof the request are committed; the server instance detecting that latercommands use a session state that was changed during the one or morecommitted transactions of the request but was not persisted by the oneor more transactions; in response, the server instance sending, to theclient in the session, a third set of information describing one or morecommands that change the session state without repeating the one or morecommitted transactions; and the server instance sending, to the clientin the session, a directive instructing the client to purge from thefirst set of information, the one or more first items that represent theone or more particular transactional commands.
 11. One or morenon-transitory storage media storing one or more sequences ofinstructions which, when executed by one or more computing devices,cause: a server instance receiving, from a client in a session betweenthe server instance and the client, a request to execute: one or moretransactional commands that, when executed, cause changes to a database,and one or more non-transactional commands that, when executed, do notcause changes to the database; the server instance sending, to theclient, at least one first directive instructing the client to store oneor more first items representing one or more particular transactionalcommands that are open but not yet committed in the session in a firstset of information and to store one or more second items representingone or more particular non-transactional commands that have beenprocessed in the session in a second set of information; determiningthat the one or more particular transactional commands have committed inthe session; and based at least in part on determining that the one ormore particular transactional commands have committed in the session,the server instance sending, to the client in the session, at least onesecond directive instructing the client to purge, from the first set ofinformation, the one or more first items that represent the one or moreparticular transactional commands without purging, from the second setof information, the one or more second items that represent the one ormore particular non-transactional commands.
 12. The one or morenon-transitory storage media of claim 11, wherein the one or moresequences of instructions include instructions which, when executed bythe one or more computing devices, cause: determining that the requesthas completed in the session; based at least in part on determining thatthe request has completed in the session, the server instance sending,to the client in the session, a third directive instructing the clientto purge, from the second set of information, the one or more seconditems that represent the one or more particular non-transactionalcommands.
 13. The one or more non-transitory storage media of claim 12,wherein the third directive instructs the client to purge, from thefirst set of information, the one or more first items that represent anytransactional command.
 14. The one or more non-transitory storage mediaof claim 11, wherein the at least one first directive comprises at leastone directive instructing the client to store, in the second set ofinformation, the one or more second items that represent the one or moreparticular non-transactional commands.
 15. The one or morenon-transitory storage media of claim 14, wherein the one or moresequences of instructions include instructions which, when executed bythe one or more computing devices, cause: determining that theparticular one or more non-transactional commands have been processed inthe session; based at least in part on determining that the particularone or more non-transactional commands have been processed in thesession, the server instance sending, to the client in the session, oneor more directives instructing the client to maintain, in the second setof information, the one or more second items that represent the one ormore particular non-transactional commands.
 16. The one or morenon-transitory storage media of claim 11, wherein a first data structureis used to store the first set of information is stored; and wherein asecond data structure is used to store the second set of information.17. The one or more non-transitory storage media of claim 16, whereinthe first data structure is a first queue and the second data structureis a second queue.
 18. The one or more non-transitory storage media ofclaim 11, wherein the session has a static state indicating that sessionstate changes for the session occur as part of session initialization oroutside of any transaction; and wherein the server instance sends the atleast one second directive in response to committing any transaction inthe session.
 19. The one or more non-transitory storage media of claim11, wherein the one or more sequences of instructions includeinstructions which, when executed by the one or more computing devices,cause: detecting that a transaction in the request sets anon-transactional session state; determining whether later commands inthe request use the non-transactional session state; if it is determinedthat later commands do not use the non-transactional session state,after committing the transaction, the server instance sending, to theclient in the session, at least one directive instructing the client topurge, from the first set of information and the second set ofinformation, the one or more first items that represent the one or moreparticular transactional commands and the one or more second items thatrepresent the one or more particular non-transactional commands; and ifit is determined that later commands use the non-transactional sessionstate, after committing the transaction, the server instance sending, tothe client in the session, a directive instructing the client to purge,from the first set of information, the one or more first items thatrepresent the one or more particular transactional commands.
 20. The oneor more non-transitory storage media of claim 11, wherein the one ormore sequences of instructions include instructions which, when executedby the one or more computing devices, cause: the server instancedetecting that one or more transactions of the request are committed;the server instance detecting that later commands use a session statethat was changed during the one or more committed transactions of therequest but was not persisted by the one or more transactions; inresponse, the server instance sending, to the client in the session, athird set of information describing one or more commands that change thesession state without repeating the one or more committed transactions;and the server instance sending, to the client in the session, adirective instructing the client to purge from the first set ofinformation, the one or more first items that represent the one or moreparticular transactional commands.